import 'package:flutter/material.dart';
import 'package:flutter_demo/pages/category_list_page.dart';
import 'package:get/get.dart';

class CategoryPage extends StatelessWidget {
  const CategoryPage({Key? key}) : super(key: key);

  final tabs = const ["Switch游戏", "PC游戏", "掌机资源", "休息ð"];
  final tabPages = const [CategoryListPage(0), CategoryListPage(1), CategoryListPage(2), CategoryListPage(3)];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: tabs.length,
      child: Column(
        children: [
          Container(
            color: Colors.blue,
            width: Size.infinite.width,
            child: TabBar(
              indicatorColor: Get.theme.secondaryHeaderColor,
              padding: EdgeInsets.zero,
              tabs: tabs
                  .map(
                    (e) => Padding(
                      padding: const EdgeInsets.fromLTRB(0, 8, 0, 8),
                      child: Text(
                        e,
                        style: const TextStyle(color: Colors.white),
                      ),
                    ),
                  )
                  .toList(),
              isScrollable: true,
            ),
          ),
          Expanded(
            child: TabBarView(children: tabPages),
          ),
        ],
      ),
    );
  }
}
